<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>图形绘制之编辑几何图形</title>
    <link rel="stylesheet" href="../v6.4.3/css/ol.css">
    <link rel="stylesheet" href="css/common.css">
  </head>
  <body>
    <div id="map" style="height: 90%;"></div>
    
    <script src="../v6.4.3/build/ol.js"></script>
    <script>
      var resolutions = []
      var projection = ol.proj.get('EPSG:3857')
      for(var i = 0; i < 19; i++) {
        resolutions[i] = Math.pow(2, 18 - i)
      }
      var tilegrid = new ol.tilegrid.TileGrid({
        origin: [0, 0],
        resolutions: resolutions
      })
      var baiduSource = new ol.source.TileImage({
        projection: projection,
        tileGrid: tilegrid,
        tileUrlFunction: function(tileCoord, pixelRatio, proj) {
          if(!tileCoord) {
            return ''
          }
          var z = tileCoord[0]
          var x = tileCoord[1]
          var y = tileCoord[2]
          if(x < 0) {
            x = 'M' + (-x)
          }
          if(y < 0) {
            y = 'M' + (-y)
          }
          return "http://online3.map.bdimg.com/onlinelabel/?qt=tile&x=" + x + "&y=" + y + "&z=" + z + "&styles=pl&udt=20151021&scaler=1&p=1";
        }
      })

      //百度地图
      var baiduLayer = new ol.layer.Tile({
        source: baiduSource
      })
      var map = new ol.Map({
        target: 'map',
        layers: [baiduLayer],
        view: new ol.View({
          center: [12519281, 4088382],
          zoom: 12
        })
      })


    </script>
  </body>
</html>